#include "infomw.h"
#include "ui_infomw.h"

infoMW::infoMW(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::infoMW)
{
    ui->setupUi(this);
    ui->info_textEdit->setReadOnly(true);
    QFile file("information.txt");
    if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        QTextStream in(&file);
        ui->info_textEdit->clear();
        while (!in.atEnd()) {
            QString line = in.readLine();
            ui->info_textEdit->append(line);
        }
        file.close();
    } else {
        QMessageBox::critical(this, "错误", "无法打开文件！");
    }
}

infoMW::~infoMW()
{
    delete ui;
}

void infoMW::on_back_btn_clicked()
{
    //所以可以利用此函数获取当前窗口的父窗口对象指针
    QWidget *parent = this->parentWidget();
    parent->show();//把之前父界面的隐藏状态改为显示状态，显示父界面
    this->close();//关闭当前界面
}
